package com.yufu.baidu.ocr;

import com.baidu.ocr.sdk.model.BankCardResult;
import com.getcapacitor.JSObject;

import org.json.JSONException;

public class BankCardResultJSObject {
  private final BankCardResult original;
  private final String bankCardNumber;
  private final String bankName;
  private final BankCardResult.BankCardType bankCardType;
  private final String validDate;
  private final String holderName;

  public BankCardResultJSObject(BankCardResult original) {
    this.original = original;
    bankCardNumber = original.getBankCardNumber();
    bankName = original.getBankName();
    bankCardType = original.getBankCardType();
    validDate = original.getValidDate();
    holderName = original.getHolderHame();
  }


  public JSObject getJSObject() {
    JSObject data = new JSObject();
    data.put("bankCardNumber", this.bankCardNumber);
    data.put("bankName", this.bankName);
    data.put("bankCardType", this.bankCardType);
    data.put("validDate", this.validDate);
    data.put("holderName", this.holderName);
    try {
      JSObject original = new JSObject(this.original.getJsonRes());
      data.put("original", original);
    } catch (JSONException e) {
      e.printStackTrace();
    }
    return data;
  }
}
